#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
int subarraySum(vector<int>& nums, int k) {
    unordered_map<int, int>hash;
    hash[0] = 1;

    int sum = 0, ret = 0;
    for (auto num : nums)
    {
        sum += num;
        if (hash.count(sum - k)) ret += hash[sum - k];
        hash[sum]++;
    }
    return ret;
}


int main()
{
    vector<int> nums = { 1,2,3 };
    subarraySum(nums, 3);
    return 0;
}